//////////////////////////////////////////
// Make Table S6
//////////////////////////////////////////


gl path "~/Dropbox/CovidTurnout/replication"

use "$path/original_data/analysis_file.dta", clear
keep if inlist(age, 64, 65)

* Turnout
reg voted age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs], r
local b1 = _b[age65_2012]
local se1 = _se[age65_2012]
local n1 = e(N)
local ba1 = _b[age65_2020]
local sea1 = _se[age65_2020]
local bi1 = _b[is2020]
local sei1 = _se[is2020]
local ba181 = _b[age65_2018]
local sea181 = _se[age65_2018]
local bi181 = _b[is2018]
local sei181 = _se[is2018]
local ba161 = _b[age65_2016]
local sea161 = _se[age65_2016]
local bi161 = _b[is2016]
local sei161 = _se[is2016]
local ba141 = _b[age65_2014]
local sea141 = _se[age65_2014]
local bi141 = _b[is2014]
local sei141 = _se[is2014]
local c1 = _b[_cons]

reghdfe voted age65_2020 age65_2012 age65_2014 age65_2016 age65_2018 [fw=obs], ///
	a(i.c#i.year) vce(robust)
local ba2 = _b[age65_2020]
local sea2 = _se[age65_2020]
local ba182 = _b[age65_2018]
local sea182 = _se[age65_2018]
local ba162 = _b[age65_2016]
local sea162 = _se[age65_2016]
local ba142 = _b[age65_2014]
local sea142 = _se[age65_2014]
local b2 = _b[age65_2012]
local se2 = _se[age65_2012]
local n2 = e(N)

* Absentee 
reg absentee age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs], r
local b3 = _b[age65_2012]
local se3 = _se[age65_2012]
local n3 = e(N)
local ba3 = _b[age65_2020]
local sea3 = _se[age65_2020]
local bi3 = _b[is2020]
local sei3 = _se[is2020]
local ba183 = _b[age65_2018]
local sea183 = _se[age65_2018]
local bi183 = _b[is2018]
local sei183 = _se[is2018]
local ba163 = _b[age65_2016]
local sea163 = _se[age65_2016]
local bi163 = _b[is2016]
local sei163 = _se[is2016]
local ba143 = _b[age65_2014]
local sea143 = _se[age65_2014]
local bi143 = _b[is2014]
local sei143 = _se[is2014]
local c3 = _b[_cons]

reghdfe absentee age65_2020 age65_2012 age65_2014 age65_2016 age65_2018 [fw=obs], ///
	a(i.c#i.year) vce(robust)
local ba4 = _b[age65_2020]
local sea4 = _se[age65_2020]
local ba184 = _b[age65_2018]
local sea184 = _se[age65_2018]
local ba164 = _b[age65_2016]
local sea164 = _se[age65_2016]
local ba144 = _b[age65_2014]
local sea144 = _se[age65_2014]
local b4 = _b[age65_2012]
local se4 = _se[age65_2012]
local n4 = e(N)

* Early Voting
reg early age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs], r
local b5 = _b[age65_2012]
local se5 = _se[age65_2012]
local n5 = e(N)
local ba5 = _b[age65_2020]
local sea5 = _se[age65_2020]
local bi5 = _b[is2020]
local sei5 = _se[is2020]
local ba185 = _b[age65_2018]
local sea185 = _se[age65_2018]
local bi185 = _b[is2018]
local sei185 = _se[is2018]
local ba165 = _b[age65_2016]
local sea165 = _se[age65_2016]
local bi165 = _b[is2016]
local sei165 = _se[is2016]
local ba145 = _b[age65_2014]
local sea145 = _se[age65_2014]
local bi145 = _b[is2014]
local sei145 = _se[is2014]
local c5 = _b[_cons]

reghdfe early age65_2020 age65_2012 age65_2014 age65_2016 age65_2018  [fw=obs], ///
	a(i.c#i.year) vce(robust)
local ba6 = _b[age65_2020]
local sea6 = _se[age65_2020]
local ba186 = _b[age65_2018]
local sea186 = _se[age65_2018]
local ba166 = _b[age65_2016]
local sea166 = _se[age65_2016]
local ba146 = _b[age65_2014]
local sea146 = _se[age65_2014]
local b6 = _b[age65_2012]
local se6 = _se[age65_2012]
local n6 = e(N)

* Election Day
reg precinct age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs], r
local b7 = _b[age65_2012]
local se7 = _se[age65_2012]
local n7 = e(N)
local ba7 = _b[age65_2020]
local sea7 = _se[age65_2020]
local bi7 = _b[is2020]
local sei7 = _se[is2020]
local ba187 = _b[age65_2018]
local sea187 = _se[age65_2018]
local bi187 = _b[is2018]
local sei187 = _se[is2018]
local ba167 = _b[age65_2016]
local sea167 = _se[age65_2016]
local bi167 = _b[is2016]
local sei167 = _se[is2016]
local ba147 = _b[age65_2014]
local sea147 = _se[age65_2014]
local bi147 = _b[is2014]
local sei147 = _se[is2014]
local c7 = _b[_cons]

reghdfe precinct age65_2020 age65_2012 age65_2014 age65_2016 age65_2018  [fw=obs], ///
	a(i.c#i.year) vce(robust)
local ba8 = _b[age65_2020]
local sea8 = _se[age65_2020]
local ba188 = _b[age65_2018]
local sea188 = _se[age65_2018]
local ba168 = _b[age65_2016]
local sea168 = _se[age65_2016]
local ba148 = _b[age65_2014]
local sea148 = _se[age65_2014]
local b8 = _b[age65_2012]
local se8 = _se[age65_2012]
local n8 = e(N)

/* 
 * Indiana data
 */ 



quietly {
	cap log close
	set linesize 255

	log using "$path/output/main_table.tex", text replace
	
	noisily dis "\begin{table}[t]"
	noisily dis "\centering"
	noisily dis "\caption{\textbf{Effect of No-Excuse Absentee Voting on Turnout and Vote Mode, Texas General Elections, 2012-2020.} \label{tab:main_texas}}"
	noisily dis "\resizebox{1\textwidth}{!}{"
	noisily dis "\begin{tabular}{lcccccccc}"
	noisily dis "\toprule \toprule"
	noisily dis " & \multicolumn{2}{c}{\textbf{Overall Turnout}} & \multicolumn{2}{c}{\textbf{Absentee Voting}} & \multicolumn{2}{c}{\textbf{Early In-Person}} & \multicolumn{2}{c}{\textbf{Election Day In-Person}}\\"
	noisily dis " & \multicolumn{2}{c}{Pr(Voted)[0-100\%]} & \multicolumn{2}{c}{Pr(Absentee)[0-100\%]} & \multicolumn{2}{c}{Pr(Early)[0-100\%]} & \multicolumn{2}{c}{Pr(Elec. Day)[0-100\%]} \\[2mm]"
	noisily dis " & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) \\"
	noisily dis "\midrule"
	noisily dis "No-Excuse (Age=65) $\times$ 2020 & \textbf{" %5.2f `ba1' "} & \textbf{" %5.2f `ba2' "} & \textbf{" %5.2f `ba3' "} & \textbf{" %5.2f `ba4' "} & \textbf{" %5.2f `ba5' "} & \textbf{" %5.2f `ba6' "} & \textbf{" %5.2f `ba7' "} & \textbf{" %5.2f `ba8' "} \\"
	noisily dis " & (" %3.2f `sea1' ") & (" %3.2f `sea2' ") & (" %3.2f `sea3' ") & (" %3.2f `sea4' ") & (" %3.2f `sea5' ") & (" %3.2f `sea6' ") & (" %3.2f `sea7' ") & (" %3.2f `sea8' ") \\[2mm]"
	noisily dis "No-Excuse (Age=65) $\times$ 2018 & " %5.2f `ba181' " & " %5.2f `ba182' "  & " %5.2f `ba183' " & " %5.2f `ba184' " & " %5.2f `ba185' " & " %5.2f `ba186' "  & " %5.2f `ba187' " & " %5.2f `ba188' " \\"
	noisily dis " & (" %3.2f `sea181' ") & (" %3.2f `sea182' ")  & (" %3.2f `sea183' ") & (" %3.2f `sea184' ")  & (" %3.2f `sea185' ") & (" %3.2f `sea186' ") & (" %3.2f `sea187' ") & (" %3.2f `sea188' ") \\[2mm]"
	noisily dis "No-Excuse (Age=65) $\times$ 2016 & " %5.2f `ba161' " & " %5.2f `ba162' "  & " %5.2f `ba163' " & " %5.2f `ba164' " & " %5.2f `ba165' " & " %5.2f `ba166' "  & " %5.2f `ba167' " & " %5.2f `ba168' " \\"
	noisily dis " & (" %3.2f `sea161' ") & (" %3.2f `sea162' ")  & (" %3.2f `sea163' ") & (" %3.2f `sea164' ")  & (" %3.2f `sea165' ") & (" %3.2f `sea166' ") & (" %3.2f `sea167' ") & (" %3.2f `sea168' ") \\[2mm]"
	noisily dis "No-Excuse (Age=65) $\times$ 2014 & " %5.2f `ba141' " & " %5.2f `ba142' "  & " %5.2f `ba143' " & " %5.2f `ba144' " & " %5.2f `ba145' " & " %5.2f `ba146' "  & " %5.2f `ba147' " & " %5.2f `ba148' " \\"
	noisily dis " & (" %3.2f `sea141' ") & (" %3.2f `sea142' ")  & (" %3.2f `sea143' ") & (" %3.2f `sea144' ")  & (" %3.2f `sea145' ") & (" %3.2f `sea146' ") & (" %3.2f `sea147' ") & (" %3.2f `sea148' ") \\[2mm]"
	noisily dis "No-Excuse (Age=65) $\times$ 2012 & " %5.2fc `b1' " & " %5.2fc `b2' " & " %5.2fc `b3' " & " %5.2fc `b4' "  & " %5.2fc `b5' " & " %5.2fc `b6' " & " %5.2fc `b7' " & " %5.2fc `b8' " \\"
	noisily dis " & (" %3.2f `se1' ") & (" %3.2f `se2' ") & (" %3.2f `se3' ") & (" %3.2f `se4' ") & (" %3.2f `se5' ") & (" %3.2f `se6' ") & (" %3.2f `se7' ") & (" %3.2f `se8' ") \\[2mm]"
	noisily dis "2020 & " %5.2f `bi1' " & & " %5.2f `bi3' " & & " %5.2f `bi5' " & & " %5.2f `bi7' " & \\"
	noisily dis " & (" %3.2f `sei1' ") & & (" %3.2f `sei3' ") & & (" %3.2f `sei5' ") & & (" %3.2f `sei7' ") & \\[2mm]"
	noisily dis "2018 & " %5.2f `bi181' " & & " %5.2f `bi183' " & & " %5.2f `bi185' " & & " %5.2f `bi187' " & \\"
	noisily dis " & (" %3.2f `sei181' ") & & (" %3.2f `sei183' ") & & (" %3.2f `sei185' ") & & (" %3.2f `sei187' ") & \\[2mm]"
	noisily dis "2016 & " %5.2f `bi161' " & & " %5.2f `bi163' " & & " %5.2f `bi165' " & & " %5.2f `bi167' " & \\"
	noisily dis " & (" %3.2f `sei161' ") & & (" %3.2f `sei163' ") & & (" %3.2f `sei165' ") & & (" %3.2f `sei167' ") & \\[2mm]"
	noisily dis "2014 & " %5.2f `bi141' " & & " %5.2f `bi143' " & & " %5.2f `bi145' " & & " %5.2f `bi147' " & \\"
	noisily dis " & (" %3.2f `sei141' ") & & (" %3.2f `sei143' ") & & (" %3.2f `sei145' ") & & (" %3.2f `sei147' ") & \\[2mm]"
	noisily dis "Intercept (2012 mean) & " %5.2f `c1' " & & " %5.2f `c3' " & & " %5.2f `c5' " & & " %5.2f `c7' " & \\[2mm]"
	noisily dis " \# Obs & " %12.0fc `n1' " & " %12.0fc `n2' " & " %12.0fc `n3' " & " %12.0fc `n4' " & " %12.0fc `n5' " & " %12.0fc `n6' " & " %12.0fc `n7' " & " %12.0fc `n8' " \\"
	noisily dis " County-by-Year FE & N & Y & N & Y & N & Y & N & Y\\"
// 	noisily dis " County-by-Age FE & N & Y & N & Y & N & Y & N & Y \\"
	noisily dis "\bottomrule \bottomrule"
	noisily dis "\multicolumn{9}{p{1.3\textwidth}}{\footnotesize Robust standard errors in parentheses. "
	noisily dis "Unit of observation is an individual by year. Texans aged 64 or younger who are eligible to vote"
	noisily dis " must provide a valid excuse if they wish to vote absentee. Those aged 65 or older who are eligible to vote can vote absentee without an excuse.}"
	noisily dis "\end{tabular}}"
	noisily dis "\end{table}"
	
	log off

}







